from EmpVoting import NetworkModifier

class AgentWeightLocalAlg(NetworkModifier):

    def __init__(self, useDynamicFields = False):
        '''
        Constructor
        '''
        self.useDynamicFields = useDynamicFields
        
    def Apply(self, network):
        #Generate agent weights
        for agent in network.agentList:
            inEdgesItter = network.graph.in_edges_iter(agent, True)
            agentWeight = 0;
            for source, dest, data in inEdgesItter:
                agentWeight += data["weight"]

            self.SetAgentField(agent, "weight", float(agentWeight))